package com.hj.dapp.business.project.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.hj.dapp.business.project.model.Project;
import com.hj.dapp.business.project.service.ProjectService;
import com.hj.dapp.common.request.PageRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.security.Principal;
import java.util.List;

/**
 * @author 胡奥程
 * @version 1.0
 * @date 2024/1/24
 */
@RestController
@RequestMapping("/project")
public class ProjectController {
    @Autowired
    private ProjectService projectService;

    @PutMapping("/save")
    public void save(@RequestBody Project project, Principal principal) {
        projectService.save(project,principal);
    }

    @GetMapping("/get/{id}")
    public Project get(@PathVariable("id") Long id) {
        return projectService.get(id);
    }
    @PostMapping("/page")
    public IPage<Project> page(@RequestBody PageRequest<Project> pageRequest) {
        return projectService.page(pageRequest);
    }
    @DeleteMapping("/delete/{id}")
    public void delete(@PathVariable("id") Long id) {
        projectService.delete(id);
    }
    @GetMapping("/list")
    public List<Project> list() {
        return projectService.list();
    }
    @PostMapping("/edit")
    public void edit(@RequestBody Project project,Principal principal) {
        projectService.edit(project,principal);
    }
}
